<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
  <th:block th:include="include :: header('初始多表格')"/>
</head>
<body class="gray-bg">
<div class="container-div">
  <div class="row">
    <div class="col-sm-12">
      <div class="row">
        <!-- 搜索区 -->
        <div class="col-sm-12 search-collapse">
          <form id="grid-project-search">
            <div class="select-list">
              <ul>
                <li>
                  <label>项目ID: </label>
                  <input type="text" name="projectId"/>
                </li>
                <li>
                  <label>项目名称: </label>
                  <input type="text" name="projectName"/>
                </li>
                <li>
                  <a class="btn btn-primary btn-rounded btn-sm"
                     onclick="$.table.search('grid-project-search', 'grid-project-table')"><i
                      class="fa fa-search"></i>&nbsp;搜索</a>
                  <a class="btn btn-warning btn-rounded btn-sm"
                     onclick="$.form.reset('grid-project-search', 'grid-project-table')"><i
                      class="fa fa-refresh"></i>&nbsp;重置</a>
                </li>
              </ul>
            </div>
          </form>
        </div>
        <!-- 工具区 -->
        <div class="btn-project-sm" id="grid-project-toolbar" role="project">
          <a class="btn btn-success" onclick="$.operate.add()">
            <i class="fa fa-plus"></i> 新增
          </a>
          <a class="btn btn-primary single disabled" onclick="$.operate.edit()">
            <i class="fa fa-edit"></i> 修改
          </a>
          <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
            <i class="fa fa-remove"></i> 删除
          </a>
        </div>
        <!-- 列表区 -->
        <div class="col-xs-12 select-table table-striped">
          <table id="grid-project-table"></table>
        </div>
      </div>
    </div>
  </div>
</div>
<div th:include="include :: footer"></div>
<div th:include="include :: bizdk"></div>
</body>
<script th:inline="javascript">
		var prefix = ctx + "gen/project";

		$(function() {
				var options = {
					id: "grid-project-table",
					formId: "grid-project-search",
					toolbar: "grid-project-toolbar",
					url: prefix + "/page",
					createUrl: prefix + "/add",
					removeUrl: prefix + "/delete",
					updateUrl: prefix + "/edit/{id}",
					modalName: "项目管理",
					uniqueId: "id",
					responseHandler: bizdk.pageResponseHandler,
					columns: [{
							checkbox: true
					},
					{
							field : 'id',
							title : 'ID'
					},
					{
							field : 'name',
							title : '项目名称'
					},
					{
							field : 'pkgName',
							title : '包路径'
					},
					{
							field : 'modelName',
							title : '模块名称'
					},
					{
							field : 'templatePath',
							title : '模板路径'
					},
					{
							field : 'genType',
							title : '生成方式'
					},
					{
							field : 'codePath',
							title : '输出地址'
					},
					{
							field : 'version',
							title : '版本'
					},
					{
							field : 'author',
							title : '作者'
					},
					{
							field : 'email',
							title : 'email'
					},
					{
							title: '操作',
							width: '150px',
							align: 'center',
							formatter: function(value, row, index) {
									var actions = [];
									actions.push('<a class="btn btn-success btn-xs" href="###" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
									actions.push('<a class="btn btn-danger btn-xs" href="###" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
									return actions.join('');
							}
					}]
				};
				$.table.init(options);
		});
		function openTab(event) {
				if (window.event) {    // 早期版本IE浏览器
					window.event.returnValue = false;
				} else {               //标准浏览器
					event.preventDefault();
				}
				console.log(window.parent)
				var obj = event.target || window.event.srcElement; // 处理兼容问题: 触发此事件的元素对象
				var $target = $(obj);
				
				var dataUrl = $target.attr('href');
				var dataIndex = $target.attr('index');
				var menuName = $target.attr('title') || $.trim($target.text());
				var isRefresh = $target.attr("refresh");
				var flag = true;
				window.parent.addTab(dataUrl, dataIndex, menuName, isRefresh, flag);
				return false;
		}

</script>
</html>